Emit row-has-child-toggled when a first node becomes visible in a level
authorKristian Rietveld <kris@gtk.org>
Sat, 5 Sep 2009 14:41:09 +0000 (16:41 +0200)
committerKristian Rietveld <kris@gtk.org>
Sat, 5 Sep 2009 15:15:42 +0000 (17:15 +0200)
If we have a level with zero visible nodes and the first node becomes
visible in that level, then parent has just become a "real" parent node.
In such a case we need to emit row-has-child-toggled.  This only applies
to non-root levels that have a parent.  This problem was also found when
writing the unit test, the respective cases in the unit test have been
corrected.

This fixes bugs:
 Bug 372010 - Filtering not working properly
 Bug 525965 - Filtered and sorted GtkTreeView is missing rows

gtk/gtktreemodelfilter.c
gtk/tests/filtermodel.c

index 103663606c71590361046b36858104aeab62806e..2dd41ef7f2ff9b3c3da020166c122e5d05b0471f 100644 (file)
@@ -1336,6 +1336,21 @@ gtk_tree_model_filter_row_changed (GtkTreeModel *c_model,
 
       gtk_tree_model_row_inserted (GTK_TREE_MODEL (filter), path, &iter);
 
+      if (level->parent_level && level->visible_nodes == 1)
+        {
+          /* We know that this is the first visible node in this level, so
+           * we need to emit row-has-child-toggled on the parent.  This
+           * does not apply to the root level.
+           */
+
+          gtk_tree_path_up (path);
+          gtk_tree_model_get_iter (GTK_TREE_MODEL (filter), &iter, path);
+
+          gtk_tree_model_row_has_child_toggled (GTK_TREE_MODEL (filter),
+                                                path,
+                                                &iter);
+        }
+
       if (gtk_tree_model_iter_children (c_model, &children, c_iter))
         gtk_tree_model_filter_update_children (filter, level, elt);
     }
index 52e0d5102b4826a05ac747afc699a8b32f474aa4..4a31aa3dddb5dfe023444df33040a3ebf40bc0f6 100644 (file)
@@ -856,8 +856,9 @@ filled_hide_child_levels (FilterTest    *fixture,
   check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
   check_level_length (fixture->filter, "0:4", 0);
 
-  /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
   signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
+  /* Once 0:4:0 got inserted, 0:4 became a parent */
+  signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
   signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:0");
   signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
   signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4:1");
@@ -1048,11 +1049,12 @@ filled_vroot_hide_child_levels (FilterTest    *fixture,
   check_level_length (fixture->filter, "0:3", LEVEL_LENGTH);
   check_level_length (fixture->filter, "0:4", 0);
 
-  /* FIXME: We are missing a row-has-child-toggled signal for path "0:4" */
   /* FIXME: Inconsistency!  For the non-vroot case we also receive two
    * row-has-child-toggled signals here.
    */
   signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:0");
+  /* Once 0:4:0 got inserted, 0:4 became a parent */
+  signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:4");
   signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:4:1");
   set_path_visibility (fixture, "2:0:4:2", TRUE);
   set_path_visibility (fixture, "2:0:4:4", TRUE);
@@ -1080,6 +1082,7 @@ empty_show_nodes (FilterTest    *fixture,
   check_level_length (fixture->filter, "0", 0);
 
   signal_monitor_append_signal (fixture->monitor, ROW_INSERTED, "0:0");
+  signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0");
   signal_monitor_append_signal (fixture->monitor, ROW_HAS_CHILD_TOGGLED, "0:0");
   set_path_visibility (fixture, "3:2", TRUE);
   check_filter_model (fixture);